package zhongbo.java.air.airmonitor.web.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zhongbo.java.air.airmonitor.model.AirAlertLog;
import zhongbo.java.air.airmonitor.service.IAirAlertLogService;
import zhongbo.java.air.common.vo.PageVo;
import zhongbo.java.air.common.vo.ResultVo;

@RestController
@RequestMapping("/alertLog")
@Api(tags = "告警日志记录")
public class AirAlertLogController {

    @Autowired
    private IAirAlertLogService<AirAlertLog> airAlertLogService;

    @PostMapping("/add")
    @ApiOperation("添加数据")
    public ResultVo<AirAlertLog> insert(@RequestBody AirAlertLog airAlertLog){
        AirAlertLog insert = airAlertLogService.insert(airAlertLog);
        return ResultVo.ok(insert);
    }

//    @PutMapping("/updateById")
    @PostMapping("edit")
    @ApiOperation("修改数据")
    public ResultVo<AirAlertLog> updateById(@RequestBody AirAlertLog airAlertLog){
        AirAlertLog updateById = airAlertLogService.updateById(airAlertLog);
        return ResultVo.ok(updateById);
    }

//    @DeleteMapping("/delete")
    @GetMapping("delete")
    @ApiOperation("删除数据")
    public ResultVo<String> deleteById(String entityId){
        String s = airAlertLogService.deleteById(entityId);
        return ResultVo.ok(s);
    }

//    @GetMapping("/queryById/{id}")
    @GetMapping("findOne")
    @ApiOperation("查询数据")
    public ResultVo<AirAlertLog> queryById(String entityId){
        AirAlertLog airAlertLog = airAlertLogService.queryById(entityId);
        return ResultVo.ok(airAlertLog);
    }

//    @GetMapping("/queryByPage")
    @GetMapping("findPage")
    @ApiOperation("分页查询")
    public ResultVo<PageVo<AirAlertLog>> queryByPage(Integer pageNum, Integer pageSize
            , String keyword, String fields
            , String oderByField, Boolean orderByAsc){
        PageVo<AirAlertLog> airAlertLogPageVo = airAlertLogService.queryByPage(pageNum, pageSize, keyword, fields, oderByField, orderByAsc);
        return ResultVo.ok(airAlertLogPageVo);
    }

}
